//
//  main.m
//  03-BookManageSystem
//
//  Created by mafeng on 16/7/6.
//  Copyright © 2016年 mafeng. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "BookManager.h"
#import "Book.h"
int main(int argc, const char * argv[]) {
//    截取字符串 "20|https://www.baidu.com" 中 "|" 前面和后⾯的字符串, 并输出
    NSString *str = @"20|https://www.baidu.com";
    NSArray *array = [str componentsSeparatedByString:@"|"];
    NSLog(@"%@", array);
//    向可变数组里存储 int、float、double、BOOL类型等数据(不能使用字面量)
    NSString *string = @"123.456";
    int a = [string intValue];
    float b = [string floatValue];
    double c = [string doubleValue];
    BOOL d = [string boolValue];
    NSMutableArray *mutableArray = [NSMutableArray array];
    NSNumber *cc = [NSNumber numberWithDouble:c];
    NSNumber *dd = [NSNumber numberWithBool:d];
    [mutableArray addObject:@(a)];
    [mutableArray addObject:@(b)];
    [mutableArray addObject:cc];
    [mutableArray addObject:dd];
    NSLog(@"%@", mutableArray);
//    实现图书管理系统(BookManager类)：
    NSMutableArray *bookArray = [NSMutableArray array];
    BookManager *bookManager = [BookManager bookManagerWithBookMutableArray:bookArray];
//    使用数组管理所有书籍(Book类)。
    Book *iOSbook = [Book bookWithName:@"iOS进阶" bookPrice:@(120)];
    Book *javabook = [Book bookWithName:@"java进阶" bookPrice:@(100)];
    Book *cbook = [Book bookWithName:@"C放弃" bookPrice:@(240)];
//    BookManager类属性数组可以添加、删除。
    [bookManager.bookMutableArray addObject:iOSbook];
    [bookManager.bookMutableArray addObject:javabook];
    [bookManager addBook:cbook];
    [bookManager removeBook:cbook];
//    可以从数组根据书名查找书籍，并修改书籍的价格。
    [bookManager revisePrice:@"java进阶" price:@(120)];
//    展示所有书籍清单（书名）
    [bookManager disPlayBook];
    return 0;
}
